/**
 * h5压缩图片
 */
export const compressImg = function(src,size){
	return new Promise((resolve,reject)=>{
		uni.getImageInfo({ src, success(res) {
				console.log('压缩前', res)
				let canvasWidth = res.width //图片原始长宽
				let canvasHeight = res.height
				let img = new Image()
				img.src = res.path
				let canvas = document.createElement('canvas');
				let ctx = canvas.getContext('2d')
				canvas.width = size>1024*8 ? canvasWidth / 5 : canvasWidth / 3
				canvas.height = size>1024*8 ? canvasHeight / 5 :canvasHeight / 3
				ctx.drawImage(img, 0, 0, canvas.width, canvas.height)
				canvas.toBlob(function(fileSrc) {
					let imgSrc = window.URL.createObjectURL(fileSrc)
					console.log('压缩后', canvas.width, imgSrc)
					resolve(imgSrc)
				})
			}
		})
	})
}